package array


func UniqBy(array []T, iteratee func(T) T) []T {
	var cacheSet = map[T]struct{}{}
	var ret []T
	for _, value := range array {
		uniqValue := iteratee(value)
		if _, ok := cacheSet[uniqValue]; !ok {
			ret = append(ret, value)
			cacheSet[uniqValue] = struct{}{}
		}
	}
	return ret
}